The present invention relates to an IC card reader/writer and method for receiving data transmitted from an IC card.
FIG. 11 shows a conventional general configuration of a reader/writer for an IC card with an external terminal (hereafter simply referred to as an IC card). IEC/ISO7816 is available as a standard regarding IC cards. In FIG. 11, numeral 1000 designates an IC card reader/writer, numeral 101 designates a CPU, and numeral 109 designates an IC card. Furthermore, in the IC card reader/writer 1000, numeral 201 designates a transmission buffer that temporarily stores transmitted data transmitted from the CPU 101. Numeral 202 designates a parity generation section that calculates the parity of the transmitted data and adds the parity. Numeral 203 designates a parallel/serial conversion section that serially transmits a start bit, transmitted data and a parity bit. Numeral 204 designates a retransmission request signal generation circuit that generates a retransmission request signal and transmits the signal to the IC card 109 when received data has a parity error. Numeral 301 designates a transmission/reception switching section that switches between transmission and reception in communication with the IC card 109. Numeral 302 designates a serial/parallel conversion section that receives the start bit, the data and the parity bit transmitted serially from the IC card 109. Numeral 303 designates a parity check section that checks the parity of the received data and gives a notification to the retransmission request signal generation circuit 204 when there is a parity error. Numeral 304 designates a reception buffer that temporarily stores the received data until the data is read by the CPU 101. Furthermore, numeral 1101 designates a pull-up resistor that switches the signal level of a data terminal (not shown) to High or Low.
Data reception at the conventional IC card reader/writer configured as described above will be described referring to FIG. 11 and FIGS. 12(a) and 12(b). FIGS. 12(a) and 12(b) show the formats of data transmitted from the IC card 109.
During nontransmission, the data terminal of the IC card 109 holds a high impedance state, and its signal level is held High by the pull-up resistor 1101. Data transmission of the IC card 109 is performed by using a character 1200 as one unit having 10 bits in total comprising a start bit 1201 having a Low signal level, data 1202 having 8 bits (Da, Db, Dc, Dd, De, Df, Dg and Dh) and a parity bit 1203. The signal level of the parity bit 1203 is set Low when the calculated number of the high signal levels in the 8-bit data 1202 is even, and is set High when the number is odd. After the parity bit 1201 is transmitted, the data terminal is restored to its high impedance state. The signal level of the data terminal is held High by the pull-up resistor 1101. On the other hand, the IC card reader/writer 1000 on the reception side compares the parity bit value calculated from the 8-bit received data 1202 with the value of the received parity bit 1203. When the value of the parity bit 1203 is correct, the reception side prepares for the reception of the next data. When the value of the parity bit 1203 is not correct, it is judged that a parity error has occurred, and the signal level of the data terminal is set Low as an error signal in the period between 1 etu at the minimum and 2 etu at the maximum after the leading edge ((10.5xc2x10.2) etu) of the start bit 1201. At this time, an error signal 1220 is placed within a character protection period 1210 as shown in FIG. 12(b). The transmission side checks the signal level of the data terminal after (11xc2x10.2) etu from the start bit, and performs the following operation.
(A) When the signal level of the data terminal is High, it is judged that reception is performed properly. (B) When the signal level of the data terminal is Low, in other words, when the error signal 1220 is received, it is judged that transmission is not performed properly, and data retransmission is performed.
It is supposed that the IC card is usually carried and used by a user; however, since the data terminal of the IC card is exposed outside, the terminal is liable to be deteriorated by friction, corrosion, etc. and affected by dirt, moisture, static electricity, etc. Hence, the IC card reader/writer is requested to perform data transmission to and reception from the IC card properly and securely against these external disturbances.
Furthermore, in order that the IC card is widely used, it is necessary to attain functions for carrying out data transmission and reception properly and securely at low cost.
Hence, it is desired that the capacity of the reception buffer, which temporarily stores received data until the data is read by the CPU, is small. However, in the case when the reception buffer receives the next data when it cannot store more data (hereafter this case is referred to as a reception overrun), there is no other choice but to discard the received data or the data having already been stored in the reception buffer, whereby the CPU cannot read the received data properly. When the capacity of the reception buffer is small, this kind of reception overrun is apt to occur. When a reception overrun occurred conventionally at the reception time of the initial response of the IC card, it was necessary to reset the IC card and to receive all data again.
Moreover, FIG. 13 shows the reception sampling timing for the data of one character on both the transmission side and the reception side. When the transmission rate on the transmission side differs from that on the reception side because a clock terminal (not shown in FIG. 11) undergoes the influence of noise or the like, differences occur between the content of 8-bit data 1302 on the side of transmitted data 1300 and the content of 8-bit data 1312 on the side of received data 1310, and the content of the data cannot be received properly in some cases as shown in FIG. 13; this kind of error cannot be detected as a parity error. Conventionally, a function of detecting this kind of transmission error was not available; as a result, the reception side received wrong data from the IC card.
In consideration of these problems in the transmission and reception of data to and from the conventional IC card, the present invention is intended to provide an IC card reader/writer and method capable of securely receiving data even when the capacity of a reception buffer is small, capable of improving the detection rate of transmission errors occurring because of the influence of noise or the like, and thus capable of attaining more secure data transmission.
One aspect of the present invention is an IC card reader/writer and method comprising:
receiving means that receives data transmitted from an IC card in predetermined processing units,
a reception buffer that temporarily stores in predetermined processing units the data received by said receiving means,
a reception buffer state flag that is set when said reception buffer results in a state of being unable to store more data,
overrun detection means that detects an overrun in the case when said reception buffer state flag has been set and when said receiving means receives new data, and discards said new data having been received, and
retransmission request means that requests said IC card to retransmit data having the same content as that of said discarded data when at least said overrun is detected.
Accordingly, data transmitted from the IC card can be received securely,
Another aspect of the present invention is the IC card reader/writer, further comprising:
a PTS flag that is set only when said IC card can retransmit data in character units, wherein
said retransmission request means requests said IC card to retransmit said received data when said overrun has been detected and said PTS flag has been set.
Accordingly, data transmitted from the IC card that can retransmit data in character units can be received securely.
Still another aspect of the present invention is the IC card reader/writer, further comprising an overrun detection flag that is set when said overrun detection means detects said overrun.
Accordingly, data transmitted from the IC card can be received securely.
Yet still another aspect of the present invention is the IC card reader/writer, further comprising:
an overrun detection counter that counts the number of said overruns detected by said overrun detection means,
a retransmission request number register that determines the maximum of the number of said overruns, and
comparing means that compares the number of said detected overruns with the number determined in said retransmission request number register, wherein
when the number of said detected overruns has reached said determined number as the result of the comparison by said comparing means, said retransmission request means does not request retransmission of data having the same content as that of said discarded data.
Accordingly, the function of securely receiving data transmitted from the IC card does not go into an infinite loop.
Still yet another aspect of the present invention is the IC card reader/writer, further comprising a retransmission request state register that notifies that the number of said detected overruns has reached the number determined in said retransmission request number register.
Accordingly, the function of securely receiving data transmitted from the IC card does not go into an infinite loop.
A further aspect of the present invention is an IC card reader/writer comprising:
receiving means that receives a signal transmitted from an IC card and including data in predetermined processing units to be transmitted with a protection period held therebetween,
signal level checking means that, in the case when said receiving means receives said data in said predetermined processing units, checks the level of said signal in a predetermined period after a predetermined reception period for receiving said data, and
retransmission request means that discards said data in said predetermined processing units and requests said IC card to retransmit data having the same content as that of said discarded data when said signal level checking means detects a predetermined level at least in the whole or parts of said signal in said predetermined period.
Accordingly, data transmitted from the IC card can be received securely.
A still further aspect of the present invention is the IC card reader/writer, wherein said signal level checking means detects the level of said signal of the minimum unit in said predetermined period immediately after said reception period.
Accordingly, data transmitted from the IC card can be received securely.
A yet further aspect of the present invention is the IC card reader/writer, further comprising:
a PTS flag that is set only when said IC card can retransmit said data in character units, wherein
said retransmission request means requests said IC card to retransmit said received data when said signal level checking means has detected said predetermined signal level in said predetermined period and said PTS flag has been set.
Accordingly, data transmitted from the IC card that can retransmit data in character units can be received securely.
A still yet further aspect present invention is the IC card reader/writer, further comprising a frame violation flag that is set when said signal level checking means detects said predetermined signal level in said predetermined period.
Accordingly, data transmitted from the IC card can be received securely.
An additional aspect of the present invention is the IC card reader/writer, further comprising:
a frame violation detection counter that counts the number of times said predetermined signal is detected in said predetermined period by said signal level checking means,
a retransmission request number register that determines the maximum of the number of times said predetermined signal is detected, and
comparing means that compares the number of times counted by said frame violation detection counter with the value of said retransmission request number register, wherein
when the number of times said predetermined signal is detected in said predetermined period has reached a predetermined number of said retransmission request number register as the result of the comparison by said comparing means, said retransmission request means does not request retransmission of data having the same character as that of said received data.
Accordingly, the function of securely receiving data transmitted from the IC card does not go into an infinite loop.
A still additional aspect of the present invention is the IC card reader/writer, further comprising a retransmission request state register that notifies that the number of times said predetermined signal level is detected in said predetermined period has reached the number determined in said retransmission request number register.
Accordingly, the function of securely receiving data transmitted from the IC card does not go into an infinite loop.
The above-mentioned IC card reader/writer of the present invention has a function of performing a check as to whether the reception buffer can store data or not, and makes a retransmission request to the IC card in the case when new data is received when the reception buffer cannot store more data. Hence, the IC card retransmits the same data; in this period, the CPU reads data from the reception buffer, whereby data can be stored in the reception buffer. As described above, the present invention is characterized in that proper data is received securely while preventing reception overruns. The present invention can provide an inexpensive IC card reader/writer, since data can be received securely even when the capacity of the reception buffer is made small.
Furthermore, when a Low signal level is detected in a period following a parity bit, wherein the signal level must be High (hereafter this case is referred to as a frame error), a retransmission request is made to the IC card, whereby it is characterized that proper data is received securely in a way similar to that described above. In the present invention, the detection rate of transmission errors occurring because of temporary differences between the data transmission rate on the reception side arid that on the transmission side due to the influence of noise or the like is improved, whereby it is possible to realize more secure data transmission.